package com.study.lambda;

import org.junit.Test;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public class TestLambda2 {

    List<Employee> emp= Arrays.asList(
            new Employee(101,"张三",18,9999.99),
            new Employee(102,"李四",59,6666.66),
            new Employee(103,"王五",27,3333.33),
            new Employee(104,"赵六",8,7777.77),
            new Employee(105,"田七",38,5555.55)
    );

    @Test
    public void test(){
        Collections.sort(emp,(e1,e2)->{
            if(e1.getAge()==e2.getAge()){
                return e1.getName().compareTo(e2.getName());
            }else{
                return e1.getAge().compareTo(e2.getAge());
            }
        });
        emp.forEach(System.out::println);
    }

    @Test
    public void test1(){
        method(100L,200L,(t1,t2)->t1+t2);
        System.out.println("======================");
        method(100L,200L,(t1,t2)->t1*t2);
    }

    public void method(Long t1,Long t2,MyFunction<Long,Long> function){
        System.out.println(function.method(t1, t2));
    }
}
